package org.opens.javaskill.thread.create;

import java.util.Arrays;

public class CreateThread {

    public static void main(String[] args) {
        Thread thread1 = new Thread();
        thread1.start();
        System.out.println(thread1);
    }

}

class CreateThread2 {

    public static void main(String[] args) {
        Thread thread1 = new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread1.start();
        System.out.println(thread1.getThreadGroup().getName());


        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        int activeCount = threadGroup.activeCount();
        System.out.println("当前活动线程数量:" + activeCount);
        Thread[] threads = new Thread[activeCount];
        threadGroup.enumerate(threads);
        Arrays.asList(threads).forEach(System.out::println);
    }

}